<?php

###########################################################################
#   Copyright (C) 2012 CDNPAL LTD by Christopher Gu                       #
#   resources@cdnpal.com                                                  #
#                                                                         #
#   coded for Php 4.3/5.X and above                                       #
#   and AllowOverride all for .htaccess                                   #
#                                                                         #
#   This program is free software released                                #
#   under the GPL version 2 license:                                      #
#   http://www.gnu.org/licenses/gpl-2.0.htm                               #
#                                                                         #
#   This program is distributed WITHOUT ANY WARRANTY                      #
#   or FITNESS FOR A PARTICULAR PURPOSE.                                  #
#                                                                         #
#   DADF-SDK                                                              #
#                                                                         #
###########################################################################

class IncomingRequestAdvertisement extends GenericDataObject
{
    protected $_primary = 'IncomingRequestAdvertisementID';
	protected $_name = 'IncomingRequestAdvertisement';
	
	public $class_member_only_incoming_request_code_size_list = array();
	
	public $class_member_only_incoming_request_filter;
	
	public $class_member_only_incoming_request_famous_brand_list = array();
	
	public function add_incoming_request_code_size($incoming_request_code_size) {
	
		$this->class_member_only_incoming_request_code_size_list[] = $incoming_request_code_size;
	}
	
	public function load_children() {
	
		$incoming_request_code_size_factory = IncomingRequestCodeSizeFactory::get_instance();
	
		$params = array();
		$params["IncomingRequestAdvertisementID"] = $this->IncomingRequestAdvertisementID;
		$incoming_request_code_size_list = $incoming_request_code_size_factory->get($params);
	
		foreach ($incoming_request_code_size_list as $incoming_request_code_size):
	
			$incoming_request_code_size->load_children();
			$this->class_member_only_incoming_request_code_size_list[] = $incoming_request_code_size;
		
		endforeach;
	
		$incoming_request_filter_factory = IncomingRequestFilterFactory::get_instance();
		$this->class_member_only_incoming_request_filter = $incoming_request_filter_factory->get_row($params);
		$this->class_member_only_incoming_request_filter->load_children();

		$incoming_request_famous_brand_factory = IncomingRequestFamousBrandFactory::get_instance();
		
		$incoming_request_famous_brand_list = $incoming_request_famous_brand_factory->get($params);
		
		foreach ($incoming_request_famous_brand_list as $incoming_request_famous_brand):
		
			$this->class_member_only_incoming_request_famous_brand_list[] = $incoming_request_famous_brand;
		
		endforeach;
	
	}
	
	public function save_children() {
	
		foreach ($this->class_member_only_incoming_request_code_size_list as $request_code_size):
	
			$incoming_request_code_size->save();
			$incoming_request_code_size->save_children();
	
		endforeach;
	
		$this->class_member_only_incoming_request_filter->save();
		$this->class_member_only_incoming_request_filter->save_children();
	
		$this->class_member_only_incoming_request_vendor_contact->save();
		$this->class_member_only_incoming_request_vendor_contact->save_children();
	
		foreach ($this->class_member_only_incoming_request_famous_brand_list as $incoming_request_famous_brand):
	
			$incoming_request_famous_brand->save();
	
		endforeach;
	
	}
	
}

